package controle;

import comando.ComandoExibeVisita;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import modelo.Inicializador;

public class ServletControlador extends HttpServlet 
{	
	private static final long serialVersionUID = 1L;
  	private ComandoExibeVisita comandoExibeVisita = new ComandoExibeVisita();

        
        
        @Override
  	public void service(HttpServletRequest request,
  						HttpServletResponse response)
  		throws ServletException, IOException 
	{		
  		String proxima = null;
	
  		try 
  		{	
  			String cmd = request.getParameter("cmd");
  							
  			if ("Adicionar Visita".equals(cmd))
  			{
//  				proxima = comandoAdiciona.executar(request);
  			}
  			else if("Adiciona Produto ao Visita".equals(cmd))
  			{
//  				proxima = comandoAdicionaProdutoVisita.executar(request);
  			}
  			else if ("Atualiza Visita".equals(cmd))
  			{
//  				proxima = comandoAtualizaVisita.executar(request);
  			}
  			else
  			{
  				proxima = comandoExibeVisita.executar(request);
  			}
  		}
  		catch (Exception e) 
  		{	
  			System.out.println("Ocorreu o erro: " + e.getMessage());
  			throw new ServletException(e);
  		}
	
  		RequestDispatcher rd;
  		rd = request.getRequestDispatcher(proxima);
  		rd.forward(request, response);
  	}
}